package com.simpou.tests.rest;

import com.simpou.tests.rest.model.SerializableObject;
import com.simpou.tests.commons.exception.TestFailedError;

import com.simpou.commons.utils.tests.TestRunner;
import com.simpou.commons.utils.tests.annot.ClassTest;
import com.simpou.commons.utils.tests.annot.TestOrder;

import org.junit.BeforeClass;
import org.junit.Test;

import org.junit.runner.RunWith;

import java.io.NotSerializableException;

import javax.ws.rs.core.MediaType;


@ClassTest(ResponseWriterTester.class)
@RunWith(TestRunner.class)
public class ResponseWriterTesterITCase {
    private static ResponseWriterTester test;

    @BeforeClass
    public static void setUpClass() throws Exception {
        test = new ResponseWriterTester(3333);
    }

    @Test
    @TestOrder(1)
    public void testSerialize() {
        final SerializableObject serializableObject = new SerializableObject();
        Exception exception;
        test.serialize(serializableObject, MediaType.APPLICATION_XML_TYPE,
            MediaType.APPLICATION_JSON_TYPE);
    }

    @Test(expected = TestFailedError.class)
    @TestOrder(1)
    public void testSerialize_error() {
        test.serialize(new NotSerializableException());
    }

    @Test
    @TestOrder(2)
    public void testStop() {
        test.stop();
    }
}
